<template>
	<view>
		<zy-title></zy-title>
		<view class="zy-page-padding">
			<view class="zy-title-bar-title zy-mt-lg"> 设置密码 </view>
			<zy-input hint="请输入原密码" password v-model="form.oldPassWord"></zy-input>
			<zy-input hint="请输入新密码" password v-model="form.passWord"></zy-input>
			<zy-input hint="请输入再次密码" password v-model="form.surepassword"></zy-input>
			
			<!-- <input class="zy-text-whitegrey zy-pv-50" placeholder="请输入原密码" v-model="form.oldPassWord" password/>
			<zy-line></zy-line>
			<input class="zy-text-whitegrey zy-pv-50" placeholder="请输入新密码" v-model="form.passWord" password/>
			<zy-line></zy-line>
			<input class="zy-text-whitegrey zy-pv-50" placeholder="请输入再次密码" v-model="form.surepassword" password/>
			<zy-line></zy-line> -->
			<zy-button class="zy-mt-100 zy-mh-lg" content="确认" @click="requestSave"></zy-button>
		</view>
	</view>
</template>

<script>
	import RouteUtil from '@/main/common/RouteUtil'
	export default {
		data() {
			return {
				form: {
					oldPassWord: '',
					passWord: '',
					surepassword: '',
				}
			}
		},
		methods: {
			requestSave(){
				if(!this.form.oldPassWord){
					uni.$toast.showToast('请输入原密码')
					return
				}
				if(!this.form.passWord){
					uni.$toast.showToast('请输入新密码')
					return
				}
				if(this.form.passWord != this.form.surepassword){
					uni.$toast.showToast('两次密码不一致')
					return
				}
				
				uni.$http.post('/api/user/updateUserPassWord', this.form).then(res=>{
					uni.$toast.showToast('修改成功')
					RouteUtil.back()
				})
			},

		}
	}
</script>

<style lang="scss">
	.parent {
		background-color: #f5f5f5;
		height: 100vh;
		padding: 0 50rpx;
	}

	.input-container {
		display: flex;
		flex-direction: row;
		align-items: center;
		height: 90rpx;
		margin-top: 30rpx;
		background-color: #ededed;
		border-radius: 10rpx;
		
		.label {
			width: 150rpx;
			height: 100%;
			line-height: 90rpx;
			font-size: 36rpx;
			color: #222;
			text-align: center;
		}
		
		.et {
			height: 100%;
			line-height: 100rpx;
			padding: 0 20rpx;
			font-size: 28rpx;
			flex: 1;
		}
	}
	
</style>